function debounce(func, wait) {
  let timeoutId = null;
  return function (...args) {
    if (timeoutId) clearTimeout(timeoutId)
    timeoutId = setTimeout(() => {
      timeoutId = null
      func.apply(this, args)
    }, awit)
  }

}


function deBounce(func, awit, immediate) {
  let timeoutId = null;
  return function (...args) {
    if (immediate && !timeoutId) {
      func.app(this, args)
    }
    if (timeoutId) clearTimeout(timeoutId)
    timeoutId = setTimeout(() => {
      timeoutId = null
      func.apply(this, args)
    }, awit)
  }
}